From 5445cbc7b0fd54d57229f9127084be0afc5f416f Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann?= Date: Sat, 4 Sep 2004 00:44:04 +0000 Subject: [PATCH] Accelerate the animation when it has been running for a while. (#143647). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Sat Sep 4 02:38:57 2004 Søren Sandmann * gtk/gtktoolbar.c (position): Accelerate the animation when it has been running for a while. (#143647). --- ChangeLog | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ ChangeLog.pre-2-6 | 5 +++++ ChangeLog.pre-2-8 | 5 +++++ gtk/gtktoolbar.c | 27 +++++++++++++++++++++++---- 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e9889d8a84..93a8896317 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Sep 4 02:38:57 2004 Søren Sandmann + + * gtk/gtktoolbar.c (position): Accelerate the animation when it + has been running for a while. (#143647). + 2004-09-03 Tor Lillqvist * gtk-zip.sh.in: List the three theme gtkrc files separately, zip diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e9889d8a84..93a8896317 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +Sat Sep 4 02:38:57 2004 Søren Sandmann + + * gtk/gtktoolbar.c (position): Accelerate the animation when it + has been running for a while. (#143647). + 2004-09-03 Tor Lillqvist * gtk-zip.sh.in: List the three theme gtkrc files separately, zip diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index e9889d8a84..93a8896317 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +Sat Sep 4 02:38:57 2004 Søren Sandmann + + * gtk/gtktoolbar.c (position): Accelerate the animation when it + has been running for a while. (#143647). + 2004-09-03 Tor Lillqvist * gtk-zip.sh.in: List the three theme gtkrc files separately, zip diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index e9889d8a84..93a8896317 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +Sat Sep 4 02:38:57 2004 Søren Sandmann + + * gtk/gtktoolbar.c (position): Accelerate the animation when it + has been running for a while. (#143647). + 2004-09-03 Tor Lillqvist * gtk-zip.sh.in: List the three theme gtkrc files separately, zip diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index b60a7f89ba..9896604985 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -53,6 +53,7 @@ #include "gtkvbox.h" #include "gtkimage.h" #include "gtkseparatormenuitem.h" +#include typedef struct _ToolbarContent ToolbarContent; @@ -71,7 +72,8 @@ typedef struct _ToolbarContent ToolbarContent; * in the homogeneous game. In units of * pango_font_get_estimated_char_width(). */ -#define SLIDE_SPEED 600 /* How fast the items slide, in pixels per second */ +#define SLIDE_SPEED 600.0 /* How fast the items slide, in pixels per second */ +#define ACCEL_THRESHOLD 0.18 /* After how much time in seconds will items start speeding up */ #define MIXED_API_WARNING \ "Mixing deprecated and non-deprecated GtkToolbar API is not allowed" @@ -959,10 +961,27 @@ gtk_toolbar_size_request (GtkWidget *widget, static gint position (gint from, gint to, gdouble elapsed) { + gint n_pixels; + + if (elapsed <= ACCEL_THRESHOLD) + { + n_pixels = SLIDE_SPEED * elapsed; + } + else + { + /* The formula is a second degree polynomial in + * @elapsed that has the line SLIDE_SPEED * @elapsed + * as tangent for @elapsed == ACCEL_THRESHOLD. + * This makes @n_pixels a smooth function of elapsed time. + */ + n_pixels = (SLIDE_SPEED / ACCEL_THRESHOLD) * elapsed * elapsed - + SLIDE_SPEED * elapsed + SLIDE_SPEED * ACCEL_THRESHOLD; + } + if (to > from) - return MIN (from + SLIDE_SPEED * elapsed, to); + return MIN (from + n_pixels, to); else - return MAX (from - SLIDE_SPEED * elapsed, to); + return MAX (from - n_pixels, to); } static void @@ -1459,7 +1478,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget, else size = available_size; - /* calculate widths of items */ + /* calculate widths and states of items */ overflowing = FALSE; for (list = priv->content, i = 0; list != NULL; list = list->next, ++i) { -- 2.30.2